<template>
  <div class="app-container">
    <el-table
      v-loading="listLoading"
      :data="list"
      element-loading-text="Loading"
      border
      fit
      highlight-current-row
    >
      <el-table-column align="center" label="#ID" width="100px">
        <template slot-scope="scope">
          {{ scope.$index }}
        </template>
      </el-table-column>
      <el-table-column label="用户名">
        <template slot-scope="scope">
          {{ scope.row.userName }}
        </template>
      </el-table-column>
      <el-table-column class-name="status-col" label="认证结果"  align="center">
        <template slot-scope="scope">
          <el-tag :type="scope.row.status | statusFilter">{{ scope.row.status }}</el-tag>
        </template>
      </el-table-column>
      <el-table-column align="center" prop="created_at" label="认证时间" >
        <template slot-scope="scope">
          <i class="el-icon-time" />
          <span>{{ scope.row.display_time }}</span>
        </template>
      </el-table-column>
      <el-table-column label="IP地址"  align="center">
        <template slot-scope="scope">
          <span>{{ scope.row.networkAddress }}</span>
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>

<script>
// import { getUserServiceAuthData } from '@/api/table'
import { getUserServiceAuthData } from '@/api/user-service-data'

export default {
  name: 'ServiceAuthData',
  filters: {
    statusFilter(status) {
      const statusMap = {
        '认证成功': 'success',
        // draft: 'gray',
        '认证失败': 'danger'
      }
      return statusMap[status]
    }
  },
  data() {
    return {
      list: null,
      listLoading: true
    }
  },
  created() {
    this.fetchData()
  },
  methods: {
    fetchData() {
      this.listLoading = true
      getUserServiceAuthData().then(response => {
        this.list = response.data.items
        this.listLoading = false
      })
      // console.log(getUserServiceAuthData())
    }
  }
}
</script>
